
import os.path

def PrefixSources(srcdir, srcs):
    return  [os.path.join(srcdir, x) for x in srcs]


env = Environment()

env['CC']   = '/home/wmd/zcross/arm/bin/sjcc'
env['AS']   = '/home/wmd/zcross/arm/bin/sjcc'
env['LINK'] = '/home/wmd/zcross/arm/bin/sjcc'
env['OC']   = '/home/wmd/zcross/arm/bin/image-gen'


env.SetDefault(BINCOM = '$OC -t a -i $SOURCE -o $TARGET')
env.SetDefault(BINCOMSTR = '$BINCOMSTR')
env.Append( BUILDERS = {
  'Binary': Builder(
    action=Action('$BINCOM', '$BINCOMSTR'),
    suffix='.bin',
    src_suffix='.adx'
)})


#print( env.Dump( 'ENV' ) );

env.Append( CPPPATH = [ './arch', ] )

env.Append( CCFLAGS = [ '-cpu=cortex-A5', '-Wc', '-O1', ] )
env.Append( ASFLAGS = [ '-cpu=cortex-A5',  ] )
env.Append( LINKFLAGS = [ '-cpu=cortex-A5', '-T', 'ttt.lds', '-v' ] )


archs = env.Object( PrefixSources( './arch', [ 'start.S', 'arch_init.c', 'arch_intc.c', 'arch_print.c', 'tlsf.c', ] ) )
cores = env.Object( PrefixSources( './srcs', [ 'main.c', 'norflash.c', 'sf.c' ] ) )

prog = env.Program( 'ttt.elf', archs + cores )
obin = env.Binary( 'aflash.bin', prog )

#
#

